#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101

#include <Macros.h>
#include <CoVector.h>
#include <CoMatrix.h>
#include <CoCube.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/Models/Marketmodels/Evolvers/MarketModelVolProcess.h>
#pragma unmanaged 
#include <ql\models\marketmodels\evolvers\volprocesses\squarerootandersen.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;

using namespace Cephei::QL::Models::Marketmodels::Evolvers;
#undef HANDLE
#undef ABSTRACT
#undef STRUCT
namespace Cephei { namespace QL { namespace Models { namespace Marketmodels { namespace Evolvers { namespace Volprocesses {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of ISquareRootAndersen
	public ref class CSquareRootAndersen : 
            public CMarketModelVolProcess,
            public Cephei::QL::Models::Marketmodels::Evolvers::Volprocesses::ISquareRootAndersen
	{
	protected: 
		boost::shared_ptr<QuantLib::SquareRootAndersen>* _ppSquareRootAndersen;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::SquareRootAndersen>* _phSquareRootAndersen;
#endif
		Object^ _SquareRootAndersenOwner;     // reference to object that manages the storage for this object
	internal:
		CSquareRootAndersen (Double meanLevel, Double reversionSpeed, Double volVar, Double v0, Cephei::IVector<Double>^ evolutionTimes, UInt64 numberSubSteps_, Double w1, Double w2, Microsoft::FSharp::Core::FSharpOption<Double>^ cutPoint);
        CSquareRootAndersen (boost::shared_ptr<QuantLib::SquareRootAndersen>& childNative, Object^ owner);
        CSquareRootAndersen (QuantLib::SquareRootAndersen& childNative, Object^ owner);
        CSquareRootAndersen (CSquareRootAndersen^ copy);
        CSquareRootAndersen (System::Type^ t);
#ifdef STRUCT
        CSquareRootAndersen (QuantLib::SquareRootAndersen childNative);
#endif       
#ifdef HANDLE
		CSquareRootAndersen (QuantLib::Handle<QuantLib::SquareRootAndersen>& childNative, Object^ owner);
		CSquareRootAndersen (QuantLib::Handle<QuantLib::SquareRootAndersen> childNative);
#endif
		virtual ~CSquareRootAndersen ();
		!CSquareRootAndersen ();

	internal:
		QuantLib::SquareRootAndersen& GetReference ();
		boost::shared_ptr<QuantLib::SquareRootAndersen>& GetShared ();
		QuantLib::SquareRootAndersen* GetPointer ();
        void SetSquareRootAndersen (boost::shared_ptr<QuantLib::SquareRootAndersen> native)
        {
            if (_ppSquareRootAndersen != NULL)
                delete _ppSquareRootAndersen;
            _ppSquareRootAndersen = new boost::shared_ptr<QuantLib::SquareRootAndersen> (native);
            SetMarketModelVolProcess (boost::dynamic_pointer_cast<QuantLib::MarketModelVolProcess> (*_ppSquareRootAndersen));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::SquareRootAndersen>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
        property Cephei::QL::Models::Marketmodels::Evolvers::Volprocesses::ISquareRootAndersen^ NextPath 
        {
		    virtual Cephei::QL::Models::Marketmodels::Evolvers::Volprocesses::ISquareRootAndersen^ get () ;
        }
		virtual Double Nextstep (Cephei::IVector<Double>^ variates) ;
        property UInt64 NumberStateVariables 
        {
		    virtual UInt64 get () ;
        }
        property UInt64 NumberSteps 
        {
		    virtual UInt64 get () ;
        }
        property Cephei::IVector<Double>^ StateVariables 
        {
		    virtual Cephei::IVector<Double>^ get () ;
        }
        property Double StepSd 
        {
		    virtual Double get () ;
        }
        property UInt64 VariatesPerStep 
        {
		    virtual UInt64 get () ;
        }
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
	public ref class CSquareRootAndersen_Factory : public System::MarshalByRefObject,  public ISquareRootAndersen_Factory
	{
	public:
        virtual ISquareRootAndersen^ Create (Double meanLevel, Double reversionSpeed, Double volVar, Double v0, Cephei::IVector<Double>^ evolutionTimes, UInt64 numberSubSteps_, Double w1, Double w2, Microsoft::FSharp::Core::FSharpOption<Double>^ cutPoint);
    };
   
/*Cephei*/ } /*QL*/ } /*Models*/ } /*Marketmodels*/ } /*Evolvers*/ } /*Volprocesses */}
